package com.yjhb.android.sbz.adapter.taskmanage;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import android.view.View;
import android.widget.TextView;

import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.ManagerTask;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 创建者 zx
 * 创建时间 2020/12/9 17:46
 */
public class TaskManagerFailAdapter extends BaseRecyclerAdapter<TaskManagerFailAdapter.TaskManagerFailHolder, ManagerTask> {
    private final String TAG = "TaskManagerFailAdapter";

    public TaskManagerFailAdapter(Context context) {
        super(context);
    }

    @Override
    protected TaskManagerFailHolder getHolder(View v) {
        return new TaskManagerFailHolder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_task_manager_fail;
    }

    @Override
    public void onBindViewHolder(@NonNull final TaskManagerFailHolder taskManagerFailHolder, int i) {
        taskManagerFailHolder.nameTv.setText(entity.getTask().getName());
        taskManagerFailHolder.moneyTv.setText("（" + entity.getTask().getMoney() + "元）");
        taskManagerFailHolder.watchTv.setText("浏览次数:" + entity.getQueryCount() + "次");
        taskManagerFailHolder.totalTv.setText("悬赏名额：" + entity.getTask().getMaxStock() + "个");
        taskManagerFailHolder.successTv.setText("已完成：" + entity.getTask().getSuccess() + "个");
        taskManagerFailHolder.lastNumTv.setText(entity.getTask().getCurrentStock() + "个");
        taskManagerFailHolder.topTv.setText("失败原因：" + entity.getTask().getRejectReason());
        final int i1 = i;
        taskManagerFailHolder.reEditTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemClickListener != null) {
                    itemClickListener.onViewClick(taskManagerFailHolder.reEditTv, "reedit", i1, data.get(i1));
                }
            }
        });
        taskManagerFailHolder.apply_refund_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemClickListener != null) {
                    itemClickListener.onViewClick(taskManagerFailHolder.apply_refund_tv, "apply_refund", i1, data.get(i1));
                }
            }
        });
        taskManagerFailHolder.addMoney_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemClickListener != null) {
                    itemClickListener.onViewClick(taskManagerFailHolder.addMoney_tv, "addMoney_tv", i1, data.get(i1));
                }
            }
        });
    }


    static class TaskManagerFailHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.name_tv)
        TextView nameTv;
        @BindView(R.id.money_tv)
        TextView moneyTv;
        @BindView(R.id.watch_tv)
        TextView watchTv;
        @BindView(R.id.total_tv)
        TextView totalTv;
        @BindView(R.id.success_tv)
        TextView successTv;
        @BindView(R.id.last_tv)
        TextView lastTv;
        @BindView(R.id.last_num_tv)
        TextView lastNumTv;
        @BindView(R.id.top_tv)
        TextView topTv;
        @BindView(R.id.state_tv)
        TextView stateTv;
        @BindView(R.id.reEdit_tv)
        TextView reEditTv;
        @BindView(R.id.apply_refund_tv)
        TextView apply_refund_tv;
        @BindView(R.id.addMoney_tv)
        TextView addMoney_tv;

        TaskManagerFailHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
